// 处理时间格式
import moment from 'moment';

class dateHandler{
    // 时间戳转格式化时间
    getFormatTime(time){
        // 不传参则取当前时间
        if(!time){
            time = new Date().getTime();
        }
        if(typeof time !== 'number'){
            return console.error('请传时间戳');
        }
        console.log(time);
        if(time && time.length === 10){
          time = time*1000;
        }
        let date = moment(time);
        this.year = date.format('YYYY');
        this.month = date.format('MM');
        this.day = date.format('DD');
        this.hours = date.format('HH');
        this.minutes = date.format('mm');
        this.seconds = date.format('ss');
        this.fullYear = date.format('YYYY-MM-DD');
        this.fullMonth = date.format('MM-DD');
        this.fullTime = date.format('HH:mm:ss');
        this.fullHour = date.format('HH:mm');
        this.fullDate = date.format('YYYY-MM-DD HH:mm:ss');
    }
}

export default new dateHandler